package com.example.shopping_web_back.service;

import com.example.shopping_web_back.mapper.GoodsDetailsMapper;
import com.example.shopping_web_back.pojo.GoodsDetails;
import com.example.shopping_web_back.service.impl.GoodsDetailsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsDetailsService implements GoodsDetailsServiceImpl {

    @Autowired
    private GoodsDetailsMapper goodsDetailsMapper;

    @Override
    public void addGoodsDetails(Integer id, String imageUrl) {
        goodsDetailsMapper.addGoodsDetails(id, imageUrl);
    }

    @Override
    public void deleteGoodsDetail(String goodsDetailsImage) {
        goodsDetailsMapper.deleteGoodsDetails(goodsDetailsImage);
    }

    @Override
    public void changeGoodsDetails(GoodsDetails oldGoodsDetails, GoodsDetails newGoodsDetails) {
        String oldGoodsDetails1 = oldGoodsDetails.getGoodsDetail();
        Integer ID = newGoodsDetails.getGoodsId();
        String newGoodsDetails1 = newGoodsDetails.getGoodsDetail();
        goodsDetailsMapper.changeGoodsDetails(oldGoodsDetails1, ID, newGoodsDetails1);
    }

    @Override
    public List<GoodsDetails> getGoodsDetails(Integer id) {
        return goodsDetailsMapper.getGoodsDetails(id);
    }
}
